package com.schoolvisitors.common;

import lombok.Data;
import lombok.Getter;
import org.springframework.data.domain.Page;

import java.util.ArrayList;
import java.util.List;

@Data
public class PageResult<T> {
    private List<T> records;
    private long total;

    public static <T> PageResult<T> bind(Page<T> pages){
        PageResult<T> pageResult = new PageResult<>();
        pageResult.setRecords(pages.getContent());
        pageResult.setTotal(pages.getTotalElements());
        return pageResult;
    }

}
